package com.wuyoucar.service.impl;

import com.wuyoucar.entity.TCarinfo;
import com.wuyoucar.entity.TCarinfoSource;
import com.wuyoucar.entity.TOrder;
import com.wuyoucar.entity.TPolicy;
import com.wuyoucar.mapper.TOrderMapper;
import com.wuyoucar.service.ITOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class TOrderServiceImpl implements ITOrderService {
    @Autowired
    private TOrderMapper tOrderMapper;
    //根据用户id查询相应的订单列表
    @Override
    public List<TOrder> findAllOrders(Integer userid) {
        return tOrderMapper.selectOrderList(userid);
    }
    //根据订单id修改订单信息
    @Override
    public int modifyOrderByOrderid(TOrder order) {
        return tOrderMapper.upateOrderByOrderid(order);
    }
    //根据订单id取消订单
    @Override
    public int removeOrderByOrderid(String ordernumber) {
        return tOrderMapper.deleteOrderByOrderid(ordernumber);
    }
    //根据订单id查找订单
    @Override
    public TOrder findOrderByOrderid(String ordernumber) {
        return tOrderMapper.selectOrderByOrderid(ordernumber);
    }
    //支付订单
    @Override
    public int payOrderByOrderNumber(TOrder order) {
        return tOrderMapper.payOrder(order);
    }
   //订单支付后奖信息保存到保单中
    @Override
    public int addToPolicy(TPolicy policy) {
        return tOrderMapper.savePolicy(policy);
    }

    @Override
    public TCarinfoSource findCarInfoSource(Map<String,String> map) {
        return tOrderMapper.selectcarinfoSource(map);
    }

    @Override
    public int modifyOrderRemark(Map<String, String> map) {
        return tOrderMapper.updateOrderCheck(map);
    }


}
